package com.nononsenseapps.feeder.util

object QRScanUtils {
    fun getQRScanType(scanContent:String):QRScanReturnType=when{
        scanContent.startsWith(QRScanReturnType.FEED.type)->QRScanReturnType.FEED
        scanContent.startsWith(QRScanReturnType.ITEM.type)->QRScanReturnType.ITEM
        scanContent.startsWith(QRScanReturnType.OPML.type)->QRScanReturnType.OPML
        else ->QRScanReturnType.UN_DEFAULT
    }

    fun isOpml(scanContent:String):Boolean = scanContent.lowercase().endsWith(".opml")

    fun isFeed(scanContent:String):Boolean = false
}

enum class QRScanReturnType(val type: String) {
    UN_DEFAULT(""),FEED("feed:"),ITEM("item:"),OPML("opml:");
    fun getContent(baseString:String):String= baseString.replace("$type","")

    fun buildContent(baseString: String):String=type+baseString
}